package cn.openread.demo.multithread.thread;


import java.util.concurrent.*;

public class Callable01 implements Callable<String> {


    public static void main(String[] args) throws ExecutionException, InterruptedException, TimeoutException {
        @SuppressWarnings("unchecked")
//        FutureTask task = new FutureTask(new Callable01());
//        new Thread(task).start();
//        System.out.println("1");
//        System.out.println(task.get());
//        System.out.println("2");


                ExecutorService executorService = Executors.newSingleThreadExecutor();
        Future<?> submit = executorService.submit(new Callable01());

        System.out.println(submit.get());
        executorService.shutdown();
    }

    @Override
    public String call() throws Exception {
        Thread.sleep(1000);
        return "活好人帅";
    }


}
